package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchPumpSiteRelations;
import com.ruoyi.system.service.IDispatchPumpSiteRelationsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机泵 - 站点关联Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchPumpSiteRelations")
public class DispatchPumpSiteRelationsController extends BaseController
{
    @Autowired
    private IDispatchPumpSiteRelationsService dispatchPumpSiteRelationsService;

    /**
     * 查询机泵 - 站点关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpSiteRelations:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchPumpSiteRelations dispatchPumpSiteRelations)
    {
        startPage();
        List<DispatchPumpSiteRelations> list = dispatchPumpSiteRelationsService.selectDispatchPumpSiteRelationsList(dispatchPumpSiteRelations);
        return getDataTable(list);
    }

    /**
     * 导出机泵 - 站点关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpSiteRelations:export')")
    @Log(title = "机泵 - 站点关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchPumpSiteRelations dispatchPumpSiteRelations)
    {
        List<DispatchPumpSiteRelations> list = dispatchPumpSiteRelationsService.selectDispatchPumpSiteRelationsList(dispatchPumpSiteRelations);
        ExcelUtil<DispatchPumpSiteRelations> util = new ExcelUtil<DispatchPumpSiteRelations>(DispatchPumpSiteRelations.class);
        util.exportExcel(response, list, "机泵 - 站点关联数据");
    }

    /**
     * 获取机泵 - 站点关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpSiteRelations:query')")
    @GetMapping(value = "/{pumpSiteRelationId}")
    public AjaxResult getInfo(@PathVariable("pumpSiteRelationId") Long pumpSiteRelationId)
    {
        return success(dispatchPumpSiteRelationsService.selectDispatchPumpSiteRelationsByPumpSiteRelationId(pumpSiteRelationId));
    }

    /**
     * 新增机泵 - 站点关联
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpSiteRelations:add')")
    @Log(title = "机泵 - 站点关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchPumpSiteRelations dispatchPumpSiteRelations)
    {
        return toAjax(dispatchPumpSiteRelationsService.insertDispatchPumpSiteRelations(dispatchPumpSiteRelations));
    }

    /**
     * 修改机泵 - 站点关联
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpSiteRelations:edit')")
    @Log(title = "机泵 - 站点关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchPumpSiteRelations dispatchPumpSiteRelations)
    {
        return toAjax(dispatchPumpSiteRelationsService.updateDispatchPumpSiteRelations(dispatchPumpSiteRelations));
    }

    /**
     * 删除机泵 - 站点关联
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPumpSiteRelations:remove')")
    @Log(title = "机泵 - 站点关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pumpSiteRelationIds}")
    public AjaxResult remove(@PathVariable Long[] pumpSiteRelationIds)
    {
        return toAjax(dispatchPumpSiteRelationsService.deleteDispatchPumpSiteRelationsByPumpSiteRelationIds(pumpSiteRelationIds));
    }
}
